<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <div class="contentsize">项目信息</div>
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <!-- <el-form ref="form" :model="form" label-width="80px" :inline="true" size="mini">
                    <el-form-item label="门号:">
                        <div style="width: 190px">
                            <el-input v-model="form.mh" placeholder="请输入门号"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="楼层:">
                        <div style="width: 190px">
                            <el-input v-model="form.lc" placeholder="请输入楼层"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="房间号:">
                        <div style="width: 190px">
                            <el-input v-model="form.fjh" placeholder="请输入房间号"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="建筑面积:">
                        <div style="width: 190px">
                            <el-col :span="11">
                                <el-input v-model="form.jzmja"></el-input>
                            </el-col>
                            <el-col class="line" :span="2"><span style="font-size: 12px">至</span></el-col>
                            <el-col :span="11">
                                <el-input v-model="form.jzmjb"></el-input>
                            </el-col>
                        </div>
                    </el-form-item>
                    <el-form-item label="户型:">
                        <div style="width: 190px">
                            <el-select v-model="form.hx" placeholder="请选择户型" clearable>
                                <el-option v-for="item in hxlist" :key="item.code" :label="item.name" :value="item.code"> </el-option>
                            </el-select>
                        </div>
                    </el-form-item>
                    <el-form-item label="房屋地址:">
                        <div style="width: 190px">
                            <el-input v-model="form.fwdz" placeholder="请输入房屋地址"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="档案编号:">
                        <div style="width: 190px">
                            <el-input v-model="form.dabh" placeholder="请输入档案编号"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="onSearch" icon="el-icon-search" class="searchcolor">查询</el-button>
                        <el-button @click="reSearch" icon="el-icon-refresh" class="searchcolor">重置</el-button>
                    </el-form-item>
                </el-form> -->
            </div>
            <el-table
                :data="tableData"
                style="width: 100%"
                :header-cell-style="tableHeaderColor"
                :row-style="tablerowColor"
                :row-class-name="tableRowClassName"
                :cell-style="tablecellColor"
                border
            >
                <el-table-column prop="projectCode" label="项目编号" align="center"> </el-table-column>
                <el-table-column prop="projectName" label="项目名称" align="center" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="cityName" label="城市名称" align="center"> </el-table-column>
                <el-table-column prop="status" label="状态" align="center"> </el-table-column>
                <el-table-column prop="districtName" label="行政区名称" align="center"> </el-table-column>
                <el-table-column prop="createTime" label="维护时间" align="center"> </el-table-column>
                <el-table-column prop="projectVersion" label="项目描述" align="center"> </el-table-column>
            </el-table>
            <div class="pagination" style="float: right">
                <el-pagination
                    background
                    layout="total,prev, pager, next,jumper"
                    :total="total"
                    :current-page.sync="current"
                    :page-size="pageSize"
                    @current-change="handleCurrentChange"
                >
                </el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
import axios from 'axios';
import { roomlist, roomdelete } from '@/api/index';
export default {
    name: 'dylist',
    data() {
        return {
            total: 0,
            current: 1,
            pageSize: 10,
            form: {
                buildid: '',
                cb: '',
                cqdw: '',
                create_name: '',
                create_name_id: '',
                create_time: '',
                cx: '',
                dabh: '',
                db: '',
                fj: '',
                fjh: '',
                fwdz: '',
                fwyt: '',
                fzrq: '',
                gr: '',
                hx: '',
                id: '',
                jizumj: '',
                jzmj: '',
                jzmja: '',
                jzmjb: '',
                lc: '',
                mh: '',
                mqb: '',
                note: '',
                pgjg: '',
                qs: '',
                qzlx: '',
                status_code: 0,
                tdsyqlx: '',
                tdsyqmj: '',
                update_name: '',
                update_name_id: '',
                update_time: '',
                wyf: '',
                yz: '',
                zlc: '',
                zlsb: '',
                zsbh: '',
                zssb: '',
                current: 1, //第几页
                pageSize: 10, //每页数量
                gfdw: this.$store.getters.gfdw
            },
            tableData: [],
            hxlist: [
                { name: '全部', code: '全部' },
                { name: '一室一厅', code: '一室一厅' },
                { name: '二室一厅', code: '二室一厅' },
                { name: '二室二厅', code: '二室二厅' },
                { name: '三室二厅', code: '三室二厅' },
                { name: '其他', code: '其他' }
            ] //户型
        };
    },
    components: {},
    computed: {},
    methods: {
        // 列表样式
        tableHeaderColor({ row, column, rowIndex, columnIndex }) {
            if (rowIndex === 0) {
                return 'background:linear-gradient(to bottom, #008A94,#0ae2f2) !important;color:#ffffff;font-size:14px;';
            }
        },
        tablerowColor({ row, rowIndex }) {
            return 'height: 42px;font-size:14px;color:black';
        },
        tablecellColor() {
            return 'font-weight:700;color:#000000;border-color:#c0c0c0';
        },
        tableRowClassName({ row, rowIndex }) {
            if (rowIndex % 2 != 0) {
                return 'success-row'; //这是类名
            } else {
                return '';
            }
        },
        // 换页
        handleCurrentChange(val) {
            this.current = val;
            this.form.current = val;
            this.roomlist(this.form);
            console.log(val);
        },
        // 搜索
        onSearch() {
            this.current = 1;
            this.form.current = 1;
            this.roomlist(this.form);
            console.log('搜索');
        },
        // 重置
        reSearch() {
            this.current = 1;
            this.form = {
                buildid: '',
                cb: '',
                cqdw: '',
                create_name: '',
                create_name_id: '',
                create_time: '',
                cx: '',
                dabh: '',
                db: '',
                fj: '',
                fjh: '',
                fwdz: '',
                fwyt: '',
                fzrq: '',
                gr: '',
                hx: '',
                id: '',
                jizumj: '',
                jzmj: '',
                jzmja: '',
                jzmjb: '',
                lc: '',
                mh: '',
                mqb: '',
                note: '',
                pgjg: '',
                qs: '',
                qzlx: '',
                status_code: 0,
                tdsyqlx: '',
                tdsyqmj: '',
                update_name: '',
                update_name_id: '',
                update_time: '',
                wyf: '',
                yz: '',
                zlc: '',
                zlsb: '',
                zsbh: '',
                zssb: '',
                current: 1, //第几页
                pageSize: 10, //每页数量
                gfdw: this.$store.getters.gfdw
            };
            this.roomlist(this.form);
            console.log('搜索');
        },
        // 添加
        addnew() {
            this.$router.push({
                name: 'adddy',
                path: '/adddy'
            });
        },
        // 删除
        deleteClick(e) {
            console.log(e);
            this.$confirm('确定删除此条信息吗？')
                .then(() => {
                    let data = { id: e.id };
                    roomdelete(data).then((res) => {
                        if (res.code == 200) {
                            this.roomlist(this.form);
                            this.$message.success('删除成功');
                        }
                    });
                })
                .catch(() => {
                    this.$message.success('删除取消');
                });
        },
        // 项目列表
        roomlist(data) {
            roomlist(data).then((res) => {
                if (res.code == 200) {
                    this.tableData = res.data.records;
                    this.total = res.data.total;
                } else {
                    this.tableData = [];
                    this.total = 0;
                }
            });
        }
    },
    mounted() {
        this.roomlist(this.form);
    }
};
</script>

<style scoped>
.container {
    /* height: calc(100vh - 260px); */
    overflow: hidden;
}

.crumbs {
    background-color: #fff;
    padding: 20px 20px;
}

.indexTitle {
    margin-bottom: 20px;
}

.contentsize {
    font-size: 18px;
    font-weight: 700;
}

.handle-box {
    overflow: hidden;
}

/* 新增按钮 */
.addcolor {
    margin-bottom: 10px;
}
</style>
<style>
.success-row {
    background-color: #eaf3fb !important;
}
</style>
